<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%"
      class="spbg"
      >
      <el-table-column
        type="selection"
        width="55"
        class="xzk">
      </el-table-column>
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <div class="spxq">
              <div class="spxql">
                <!-- <el-form-item label="食谱图片"> -->
                  <img :src="props.row.r_pic" alt="">
                <!-- </el-form-item> -->
              </div>
              <div class="spxqr">
                <div>
                  <el-form-item label="点赞数量">
                    <span>{{ props.row.r_read }}</span>
                  </el-form-item>
                  <el-form-item label="收藏数量">
                    <span>{{ props.row.r_collection }}</span>
                  </el-form-item>
                  <el-form-item label="所属菜系">
                    <span>{{ props.row.sort }}</span>
                  </el-form-item>
                </div>
                <div class="xxxxq">
                  <el-form-item label="食谱简介">
                  </el-form-item>
                  <el-tooltip class="item" effect="dark"  placement="bottom-start" :content="props.row.synopsis">
                  <span>{{ props.row.synopsis }}</span>
                  </el-tooltip>
                </div>
                <div class="xxxxq">
                  <el-form-item label="食谱原料">
                  </el-form-item>
                  <el-tooltip class="item" effect="dark"  placement="bottom-start" :content="props.row.material">
                  <span>{{ props.row.material }}</span>
                  </el-tooltip>
                </div>
                <div class="xxxxq">
                  <el-form-item label="食谱做法">
                  </el-form-item>
                  <el-tooltip class="item" effect="dark" placement="bottom-start" :content="props.row.practice">
                  <span>{{ props.row.practice }}</span>
                  </el-tooltip>
                </div>
              </div>
            </div>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column
        label="食谱 ID"
        prop="rid">
      </el-table-column>
      <el-table-column
        label="食谱名称"
        prop="rname">
      </el-table-column>
      <el-table-column
        label="食谱类别"
        prop="cname">
      </el-table-column>
      <el-table-column
        label="评分"
        prop="score">
      </el-table-column>
      <el-table-column
        label="发布者"
        prop="r_uname">
      </el-table-column>
      <el-table-column
        label="操作"
        width="150">
        <template slot-scope="scope">
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<style lang='scss'>
  // .demo-table-expand {
  //   font-size: 0;
  // }
  // .demo-table-expand label {
  //   width: 90px;
  //   color: #99a9bf;
  // }
  // .demo-table-expand .el-form-item {
  //   margin-right: 0;
  //   margin-bottom: 0;
  //   width: 50%;
  // }
  .spbg{
    .spxq{
      display: flex;
      width: 80%;
      margin: 0 auto;
      >div:first-child{
        width: 20%;
        margin-right: 15px;
        text-align: center;
        align-items: center;
        img{
          // width: 100%;
          width: 160px;
          height: 120px;
          max-height: 120px;
        }
      }
      >div:last-child{
        width: 80%;
      }
      .spxqr{
        display: flex;
        flex-direction: column;
        .el-form-item__label{
          line-height: 40px;
        }
        >div:first-child{
          display: flex;
          justify-content: space-evenly;
          text-align: left;
          height: 30px;
          >div{
            width: 33%;
          }
          span{
            font-size: 14px;
          }
        }
        .el-form-item{
          // height: 40px;
          width: 70px;
        }
        span{
          display: inline-block;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .xxxxq{
          align-items: center;
          height: 25px;
          span{
            line-height: 40px;
            width: 85%;
            font-size: 14px;
          }
        }
      }
    }
  }
  .el-tooltip__popper{
    width: 635px;
    max-width: 635px;
    line-height: 20px;
  }
  .el-tooltip__popper[x-placement^=bottom]{
    margin-top: -5px;
  }
</style>

<script>
  export default {
    data() {
      return {
        tableData:[],
      }
    },
    methods: {
      getspsj(){
        let url = "/rlist";
        this.axios.get(url).then((res) => {
          console.log(res);
          this.tableData = res.data.data;
          // console.log(this.tableData)
        });
      }
    },
    mounted(){
      this.getspsj()
    }
  }
</script>